package game.module.item.logic;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import game.HallServer;
import game.entity.PlayingRole;
import game.module.item.bean.Item;
import game.module.item.dao.ItemDao;

public class ItemDaoHelper {

	private static Logger logger = LoggerFactory.getLogger(ItemDaoHelper.class);

	static class SingletonHolder {
		static ItemDaoHelper instance = new ItemDaoHelper();
	}

	public static ItemDaoHelper getInstance() {
		return SingletonHolder.instance;
	}

	public void asyncInsertItem(final Item item) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ItemDao.getInstance().addItem(item);
			}
		});
	}

	public void asyncUpdateItem(final int itemTplId, final int newCount, final int playerId, final boolean updateTime) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ItemDao.getInstance().updateItemCount(itemTplId, newCount, playerId, updateTime);
			}
		});
	}

	public static void asyncRemoveItem(final int itemTplId, final int playerId) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ItemDao.getInstance().removeItem(itemTplId, playerId);
			}
		});
	}

}
